<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
   const p =  new Promise((resolve, reject) => {
        console.log('请求数据A');
        
        try {
          
          setTimeout(() => {
           
            console.log('A数据成功');
            let data = {
              user: 'li'
            }
            resolve(data)
          }, 1500)
        } catch (e) {
          console.log(e.message);
        }
      })
      .then((value) => {
        return new Promise((resvole, reject) => {
          console.log('请求B数据');
          try {
            setTimeout(() => {
              console.log('B数据成功');
              let data1 = {
                age: 18
              }
              //es6的对象方法合并
              resvole({...value,...data1})
            }, 2000)
          } catch (e) {
            console.log(e.message);
          }
        })
      })
      .then((value)=>{
        return new Promise((resolve,reject)=>{
          throw new Error('错误')
          console.log('请求C数据');
          try{
            setTimeout(()=>{
              console.log('C数据成功');
              let data2 = {
                sex: '未知'
              }
              //es5的对象方法合并
              resolve(Object.assign({},value,data2))
            })
          }catch(e){
            console.log(e.message);
          }
        })
      })
      .then((value)=>{
        console.log(value);
      })
      .catch((reason)=>{
        console.log(reason);
      })
      console.log('p',p);//?
  </script>
</body>

</html>